<template>
  <div class="app-container">
    <el-table
      v-loading="loading"
      :data="tableList"
      :header-cell-style="thaderBack"
    >
      <el-table-column label="序号" width="80">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.$index + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="psPersonName"
        label="人员姓名"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        prop="csMineShortname"
        label="煤矿名称"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        prop="psPersonDuty"
        label="工种/职务"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        prop="psPersonDept"
        label="区队班组/部门"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        prop="psStationName"
        label="分站名称"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column prop="psMineEntertime" label="入井时间" width="200">
      </el-table-column>
      <el-table-column
        prop="psAlarmStime"
        label="报警时间"
        width="220"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        prop="psAlarmType"
        label="报警类型"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          <span>{{
            scope.row.psAlarmType == '4'
              ? '矿井超员'
              : scope.row.psAlarmType == '5'
              ? '重点区域超员'
              : scope.row.psAlarmType == '6'
              ? '限制区域有人'
              : scope.row.psAlarmType == '7'
              ? '人员超时'
              : ''
          }}</span>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="gettableList"
    />
  </div>
</template>
<script>
import { addInfo } from '@/api/personnel/realpolice'
export default {
  data() {
    return {
      activeName: 'first',
      tableList: [],
      list: [],
      timer: '',
      coalmineList: [],
      // pageNum1: 1,
      // pageSize1: 10,
      total1: null,
      queryParams: {
        pageNum: 1,
        pageSize: 10000,
        csMineShortname: '',
        csMineCode: '',
        inOutType: ''
      },
      typeList: [
        {
          value: '1',
          label: '模拟量'
        },
        {
          value: '2',
          label: '开关量'
        }
      ],
      loading: false,
      total: 0
    }
  },
  mounted() {
    this.gettableList()
    setInterval(() => {
      this.gettableList()
    }, 60000)
  },
  methods: {
    cellStyleFun() {
      return 'text-align:center'
    },
    thaderBack() {
      return {
        // background: '#0069eb',
        // color: '#fff',
        // textAlign: 'center',
        fontSize: '0.14rem'
      }
    },
    tableRowClassName({ rowIndex }) {
      if (rowIndex % 2 == 0) {
        return 'evencolor'
      } else {
        return 'oddcolor'
      }
    },
    changes() {
      this.queryParams.pageNum = '1'
      this.gettableList()
    },
    gettableList() {
      // console.log(98, queryParams)
      addInfo(this.queryParams).then(res => {
        console.log(146, res)
        this.list = res.rows
        this.total1 = res.total
        this.tableList = this.list.slice(0, 15)
        var index = 0
        this.timer = () => {
          index += 15
          if (index > this.list.length) {
            index = 0
          }
          this.tableList = []
          this.tableList = this.list.slice(index, index + 15)
        }
        setInterval(this.timer, 5000)
      })
    }
  }
}
</script>
<style  lang="scss" scoped>
.pager {
  display: none;
}
</style>

